#include "rectangle.h"


Rectangle::Rectangle(int id,double height, double width)
	: id(id), height(height), width(width), x(0), y(0)
{
	//ctor
}

Rectangle::Rectangle(int id)
	: id(id), height(0), width(0), x(0), y(0)
{
	//ctor
}


Rectangle::~Rectangle()
{
	//dtor
}

double Rectangle::area() const
{
	return height*width;
}

double Rectangle::top() const
{
	return y+height;
}

double Rectangle::bottom() const
{
	return y;
}

double Rectangle::left() const
{
	return x;
}

double Rectangle::right() const
{
	return x+width;
}

void Rectangle::place(double x, double y)
{
	this->x = x;
	this->y = y;
}

void Rectangle::size(double h, double w)
{
	height = h;
	width = w;
}

void Rectangle::rotate()
{
	double t = width;
	width = height;
	height = t;
}

int Rectangle::name() const
{
	return id;
}

std::ostream& operator << (std::ostream& out, const Rectangle& r)
{
	out<<r.left()<<" "<<r.bottom()<<" "<<r.right()-r.left()<<" "<<r.top()-r.bottom()<<std::endl;
	return out;
}

std::istream& operator >> (std::istream& in, Rectangle& r)
{
	double h,w;
	in>>w>>h;
	r.size(h,w);
	return in;
}
